home *** CD-ROM | disk | FTP | other *** search
- /* Functions for installing and executing routines. written esepcially
- for executing user-defined periodic actions within a copy operation
- without having to modify the interface to the copy routines, but could
- be used for other purposes as well.
-
- 94/01/05 aih added data parameter to task handler
- 93/12/02 aih made a little more generally usefull
- 93/10/13 aih created */
-
- #include "MemoryLib.h"
- #include "TaskLib.h"
-
- Boolean TaskValid(TaskHandle task)
- {
- if (! HandleValidSize(task, sizeof(TaskType))) return(false);
- if (! (**task).action) return(false);
- return(true);
- }
-
- void *TaskData(TaskHandle task)
- {
- require(TaskValid(task));
- return((**task).data);
- }
-
- TaskHandle TaskInsert(TaskHandle list, TaskActionType action, void *data)
- {
- TaskHandle task;
-
- require(! list || TaskValid(list));
- require(action != NULL);
- task = HandleBeginClear(sizeof(TaskType));
- (**task).action = action;
- (**task).data = data;
- return(LLHInsert(list, task));
- }
-
- TaskHandle TaskDelete(TaskHandle list, TaskHandle task)
- {
- require(! list || TaskValid(list));
- require(! task || TaskValid(task));
- if (list && task) {
- list = LLHDelete(list, task);
- HandleEnd(task);
- }
- return(list);
- }
-
- void TasksExecute(TaskHandle task)
- {
- while (task) {
- TaskHandle next = LLHNext(task);
- (**task).action(task, (**task).data);
- task = next;
- }
- }
-